/**
 * 
 */
package com.rpg.osric.player;

import com.rpg.osric.globals.OsricPlayerConsts;

/**
 * Utility class for dealing with professions.
 * @author Donald
 */
final class OsricProfessionUtil {
	/** the singleton instance of {@link OsricProfessionUtil}. */
	private static OsricProfessionUtil	instance;
	/**
	 * Gets the singleton instance of {@link OsricProfessionUtil}.
	 * @return {@link OsricProfessionUtil}
	 */
	static OsricProfessionUtil getInstance() {
		if (OsricProfessionUtil.instance == null) {
			OsricProfessionUtil.instance = new OsricProfessionUtil();
		}
		return OsricProfessionUtil.instance;
	}
	/** Hidden constructor. */
	private OsricProfessionUtil() {}
	/**
	 * Gets the base roll needed for a fighter character to hit a specific 
	 * armor class.
	 * @param level the fighter's level
	 * @param ac the armor class
	 * @return float
	 */
	float getBaseToHitFighter(final int level, final float ac) {
		float roll = 20 - ac - (level - 1);
		if (roll > 20) {
			if (roll <= 25) {
				roll = 20;
			} else {
				roll -= 5;
			}
		}
		return roll;
	}
	/**
	 * Gets the base roll needed for a thief character to hit a specific 
	 * armor class.
	 * @param level the thief's level
	 * @param ac the armor class
	 * @return float
	 */
	float getBaseToHitThief(final int level, final float ac) {
		float val = 0f;
		if (level <= 4) {
			if (ac >= 2) {
				val = 21 - ac;
			} else if (ac >= -4 && ac <= 1) {
				val = 20;
			} else if (ac <= -5) {
				val = 16 - ac;
			}
		} else if (level >= 5 && level <= 8) {
			if (ac >= 0) {
				val = 19 - ac;
			} else if (ac >= -6 && ac <= -1) {
				val = 20;
			} else if (ac <= -7) {
				val = 14 - ac;
			}
		} else if (level >= 9 && level <= 12) {
			if (ac >= -3) {
				val = 16 - ac;
			} else if (ac >= -9 && ac <= -4) {
				val = 20;
			} else if (ac <= -10) {
				val = 11 - ac;
			}
		} else if (level >= 13 && level <= 16) {
			if (ac >= -5) {
				val = 14 - ac;
			} else if (ac >= -10 && ac <= -6) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		} else if (level >= 17 && level <= 20) {
			if (ac >= -7) {
				val = 12 - ac;
			} else if (ac >= -10 && ac <= -8) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		} else if (level >= 21) {
			if (ac >= -9) {
				val = 10 - ac;
			} else if (ac == -10) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		}
		return val;
	}
	/**
	 * Gets the base roll needed for a cleric character to hit a specific 
	 * armor class.
	 * @param level the cleric's level
	 * @param ac the armor class
	 * @return float
	 */
	float getBaseToHitCleric(final int level, final float ac) {
		float val = 0f;
		if (level <= 3) {
			if (ac >= 1) {
				val = 20 - ac;
			} else if (ac >= -5 && ac <= 0) {
				val = 20;
			} else if (ac <= -6) {
				val = 15 - ac;
			}
		} else if (level >= 4 && level <= 6) {
			if (ac >= -1) {
				val = 18 - ac;
			} else if (ac >= -7 && ac <= -2) {
				val = 20;
			} else if (ac <= -8) {
				val = 13 - ac;
			}
		} else if (level >= 7 && level <= 9) {
			if (ac >= -3) {
				val = 16 - ac;
			} else if (ac >= -9 && ac <= -4) {
				val = 20;
			} else if (ac <= -10) {
				val = 11 - ac;
			}
		} else if (level >= 10 && level <= 12) {
			if (ac >= -5) {
				val = 14 - ac;
			} else if (ac >= -10 && ac <= -6) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		} else if (level >= 13 && level <= 15) {
			if (ac >= -7) {
				val = 12 - ac;
			} else if (ac >= -10 && ac <= -8) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		} else if (level >= 16 && level <= 18) {
			if (ac >= -9) {
				val = 10 - ac;
			} else if (ac == -10) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		} else if (level >= 19) {
			if (ac >= -10) {
				val = 9 - ac;
			} else if (ac <= -11) {
				val = 9 - ac;
			}
		}
		return val;
	}
	/**
	 * Gets the base roll needed for a mage character to hit a specific 
	 * armor class.
	 * @param level the mage's level
	 * @param ac the armor class
	 * @return float
	 */
	float getBaseToHitMage(final int level, final float ac) {
		float val = 0f;
		if (level <= 5) {
			if (ac >= 2) {
				val = 21 - ac;
			} else if (ac >= -4 && ac <= 1) {
				val = 20;
			} else if (ac <= -5) {
				val = 16 - ac;
			}
		} else if (level >= 6 && level <= 10) {
			if (ac >= 0) {
				val = 19 - ac;
			} else if (ac >= -6 && ac <= -1) {
				val = 20;
			} else if (ac <= -7) {
				val = 14 - ac;
			}
		} else if (level >= 11 && level <= 15) {
			if (ac >= -2) {
				val = 17 - ac;
			} else if (ac >= -8 && ac <= -3) {
				val = 20;
			} else if (ac <= -9) {
				val = 12 - ac;
			}
		} else if (level >= 16 && level <= 20) {
			if (ac >= -4) {
				val = 15 - ac;
			} else if (ac >= -10 && ac <= -5) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		} else if (level >= 21) {
			if (ac >= -6) {
				val = 13 - ac;
			} else if (ac >= -10 && ac <= -7) {
				val = 20;
			} else if (ac <= -11) {
				val = 10 - ac;
			}
		}
		return val;
	}
	/**
	 * Gets the base saving throw for an cleric character.
	 * @param level the character's level
	 * @param type the type of saving throw
	 * @return float
	 */
	float getBaseSavingThrowCleric(final int level, final int type) {
		float val = 0f;
		if (level <= 3) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 16;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 15;
				break;
			}
		} else if (level >= 4 && level <= 6) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 14;
				break;
			}
		} else if (level >= 7 && level <= 9) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 12;
				break;
			}
		} else if (level >= 10 && level <= 12) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 11;
				break;
			}
		} else if (level >= 13 && level <= 15) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 10;
				break;
			}
		} else if (level >= 16 && level <= 18) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 9;
				break;
			}
		} else if (level >= 19) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 7;
				break;
			}
		}
		return val;
	}
	/**
	 * Gets the base saving throw for a fighter character.
	 * @param level the character's level
	 * @param type the type of saving throw
	 * @return float
	 */
	float getBaseSavingThrowFighter(final int level, final int type) {
		float val = 0;
		if (level <= 2) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 16;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 17;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 17;
				break;
			}
		} else if (level >= 3 && level <= 4) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 16;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 16;
				break;
			}
		} else if (level >= 5 && level <= 6) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 14;
				break;
			}
		} else if (level >= 7 && level <= 8) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 13;
				break;
			}
		} else if (level >= 9 && level <= 10) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 11;
				break;
			}
		} else if (level >= 11 && level <= 12) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 10;
				break;
			}
		} else if (level >= 13 && level <= 14) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 8;
				break;
			}
		} else if (level >= 15 && level <= 16) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 7;
				break;
			}
		} else if (level >= 17 && level <= 18) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 6;
				break;
			}
		} else if (level >= 19) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 5;
				break;
			}
		}
		return val;
	}
	/**
	 * Gets the base saving throw for a mage character.
	 * @param level the character's level
	 * @param type the type of saving throw
	 * @return float
	 */
	float getBaseSavingThrowMage(final int level, final int type) {
		float val = 0;
		if (level >= 1 && level <= 5) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 12;
				break;
			}
		} else if (level >= 6 && level <= 10) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 10;
				break;
			}
		} else if (level >= 11 && level <= 15) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 8;
				break;
			}
		} else if (level >= 16 && level <= 20) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 6;
				break;
			}
		} else if (level >= 21) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 4;
				break;
			}
		}
		return val;
	}
	/**
	 * Gets the base saving throw for a paladin character.
	 * @param level the character's level
	 * @param type the type of saving throw
	 * @return float
	 */
	float getBaseSavingThrowPaladin(final int level, final int type) {
		float val = 0;
		if (level >= 1 && level <= 2) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 15;
				break;
			}
		} else if (level >= 3 && level <= 4) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 14;
				break;
			}
		} else if (level >= 5 && level <= 6) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 12;
				break;
			}
		} else if (level >= 7 && level <= 8) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 11;
				break;
			}
		} else if (level >= 9 && level <= 10) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 9;
				break;
			}
		} else if (level >= 11 && level <= 12) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 8;
				break;
			}
		} else if (level >= 13 && level <= 14) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 6;
				break;
			}
		} else if (level >= 15 && level <= 16) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 5;
				break;
			}
		} else if (level >= 17 && level <= 18) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 4;
				break;
			}
		} else if (level >= 19) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 3;
				break;
			}
		}
		return val;
	}
	/**
	 * Gets the base saving throw for a ranger character.
	 * @param level the character's level
	 * @param type the type of saving throw
	 * @return float
	 */
	float getBaseSavingThrowRanger(final int level, final int type) {
		float val = 0;
		if (level >= 1 && level <= 2) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 16;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 17;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 17;
				break;
			}
		} else if (level >= 3 && level <= 4) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 16;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 16;
				break;
			}
		} else if (level >= 5 && level <= 6) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 14;
				break;
			}
		} else if (level >= 7 && level <= 8) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 13;
				break;
			}
		} else if (level >= 9 && level <= 10) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 11;
				break;
			}
		} else if (level >= 11 && level <= 12) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 10;
				break;
			}
		} else if (level >= 13 && level <= 14) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 8;
				break;
			}
		} else if (level >= 15 && level <= 16) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 7;
				break;
			}
		} else if (level >= 17 && level <= 18) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 5;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 6;
				break;
			}
		} else if (level >= 19) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 2;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 3;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 5;
				break;
			}
		}
		return val;
	}
	/**
	 * Gets the base saving throw for an assassin or thief character.
	 * @param level the character's level
	 * @param type the type of saving throw
	 * @return float
	 */
	float getBaseSavingThrowThief(final int level, final int type) {
		float val = 0f;
		if (level <= 4) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 16;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 15;
				break;
			}
		} else if (level >= 5 && level <= 8) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 15;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 13;
				break;
			}
		} else if (level >= 9 && level <= 12) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 14;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 11;
				break;
			}
		} else if (level >= 13 && level <= 16) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 13;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 10;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 9;
				break;
			}
		} else if (level >= 17 && level <= 20) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 6;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 12;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 9;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 7;
				break;
			}
		} else if (level >= 21) {
			switch (type) {
			case OsricPlayerConsts.SAVE_VS_WANDS:
				val = 4;
				break;
			case OsricPlayerConsts.SAVE_VS_BREATH:
				val = 11;
				break;
			case OsricPlayerConsts.SAVE_VS_DEATH:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PARALYSIS:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_POISION:
				val = 8;
				break;
			case OsricPlayerConsts.SAVE_VS_PETRIFICATION:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_POLYMORPH:
				val = 7;
				break;
			case OsricPlayerConsts.SAVE_VS_SPELLS:
				val = 5;
				break;
			}
		}
		return val;
	}
}
